<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/jquery.min.js"></script>
</head>
<body>
    <input type="text"> <span></span>
</body>
<script>
    $(function(){
        var reg = /^[\w-]{6,16}$/;
        $('input').blur(function(){
            if(reg.test($(this).val())){
                $('span').text('验证成功').css('color','green')
            }else{
                $('span').text('验证失败，请输入').css('color','red')
            }
        })
    })
</script>
</html>